#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <error.h>
#include <errno.h>


int main(void)
{
    pid_t pid;
    int i;

    setbuf(stdout, NULL);

    if ((pid = fork()) < 0)
        error_at_line(EXIT_FAILURE, errno, __FILE__, __LINE__, "FATAL");

    if (pid == 0) {
        for (i = 0; i < 10; i++) {
            printf("PID: %d Parent PID: %d\n", getpid(), getppid());
            sleep(1);
        }
    } else {
        for (i = 10; i < 15; i++) {
            printf("PID: %d Parent PID: %d\n", getpid(), getppid());
            sleep(1);
        }
        exit(EXIT_SUCCESS);
    }

    exit(EXIT_SUCCESS);
}
